package com.lm.netdemo01;

import javax.xml.crypto.Data;
import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class LiminServer {
    public static void main(String[] args) throws IOException {
        ServerSocket sc = new ServerSocket(8888);

        System.out.println("服务器启动,开始侦听!!!");

        Socket accept = sc.accept();

        InputStream is = accept.getInputStream();
        DataInputStream dis = new DataInputStream(is);
        String str = dis.readUTF();

        System.out.println("客户端:"+str);

        OutputStream os = accept.getOutputStream();
        DataOutputStream dos = new DataOutputStream(os);
        dos.writeUTF("我是服务器，我接收到了你的消息!!!");

        dos.close();
        os.close();
        dis.close();
        is.close();
        accept.close();
        sc.close();
    }
}
